package GUILayer;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class SaleUI extends JPanel {

	/**
	 * Create the panel.
	 */
	private JPanel orderUI;
	
	private static final long serialVersionUID = 1L;
	
	public SaleUI() {
		initialize();
	}
	
	public void initialize() {
		this.setLayout(new BorderLayout(0, 0));

		final JTabbedPane subMenu = new SubMenuTabbedPane();
		this.add(subMenu, BorderLayout.CENTER);
		
		JPanel offerUI = new OfferUI(this);
		subMenu.add(offerUI, "Offers");
		
		orderUI = new OrderUI();
		subMenu.add(orderUI, "Orders");
		
		subMenu.addChangeListener(new ChangeListener() {
		      public void stateChanged(ChangeEvent e) {
		        if(subMenu.getSelectedIndex() == 1)
		        {
		        	((OrderUI) orderUI).showAllOrders();
		        }
		      }
		    });
	}
	
	public JPanel getOrderUI() {
		return orderUI;
	}

}
